$("img").click(function () {
		if($(this).attr("src")=="images/true.gif"&&$(this).attr("src")!=="images/r.gif") {
			$(this).attr("src",'images/false.gif');
			var id=$(this).attr("id");
			$("[name=id"+id+"]").attr("disabled",true);
		}else if($(this).attr("src")!=="images/r.gif"){
			$(this).attr("src",'images/true.gif');
			var id=$(this).attr("id");
			$("[name=id"+id+"]").attr("disabled","");
		}
	});


function getSelectList(sendtext){
	xmlDataRequest("get_data",sendtext,function(data){
		var groupList = '';var ivrList='<option value="">'+trunk.attendent+'</option>';
		$(data).find("item").each(function(){
		if($(this).attr("id")=="758"&&$(this).attr("value") !==""){
  			groupList +='<option value="'+$(this).attr("line_id")+'">'+$(this).attr("value")+'</option>';
  		}else if($(this).attr("id")=="771"){
  			var listarray = $(this).attr("value").split("|");
  			var ring = new Array();
  			var n=0;
  			for(var s = 0; s < listarray.length; s++){
  				if(listarray[s].indexOf("user")>=0||listarray[s].indexOf("welcome")>=0){
  			    	 ring[n] = listarray[s].split(".")[0];
  			    	 n++;
  			    }
  			}
  			var truearray = unique(ring);
  			for(var i =0 ;i <truearray.length; i++){
  				ivrList += '<option>'+truearray[i]+'</option>';
  			}
  		 $("#id468").html(ivrList);
  		}
  	});
  		$("#id653").html(groupList);
  });
}

$("[name=submit]").click(function () {
		$(".errormsg").html('');
		var nonames = new Array("checkid","checklineall","ok","reset","","submit","lineGroup","id366","id584");
		var settext ='';
		var lineGroup = $("#lineGroup").attr("truevalue");
		if(lineGroup.indexOf(",")>=0){
			var lineList = lineGroup.split(",");
			for(var i =0; i < lineList.length;i++){
				settext+="&line_id="+lineList[i];
				}
		}else{
			settext+="&line_id="+$("#lineGroup").attr("truevalue");
		}
		
		$("img").each(function () {
			if($(this).attr("src")=="images/true.gif") {
				var imgid=$(this).attr("id");
				var sendname="id"+imgid;
				if($("[name="+sendname+"]").attr('type')=='checkbox') {
					settext+="&"+sendname+"="+gettruevalue(sendname,$.trim($("[name="+sendname+"]").val()));
				}else if($("[name="+sendname+"]").attr('type')=='radio'&&$("[name="+sendname+"]").attr('checked')){
					settext+="&"+sendname+"="+$.trim($("[name="+sendname+"]").val());
				}else if(sendname=="id366"){
					if($("[name=id366]").val()=="0") {
						settext+="&id366=0&id600=0";
					}else if($("[name=id366]").val()=="1") {
						settext+="&id366=1&id600=0";
					}else if($("[name=id366]").val()=="2") {
						settext+="&id366=2&id600=0";
					}else if($("[name=id366]").val()=="3") {
						settext+="&id366=0&id600=1";
					}else if($("[name=id366]").val()=="4") {
						settext+="&id366=0&id600=2";
					}
				}else if(sendname=="id584"){
					if($("[name=id584]").val()=="on") {
						settext+="&id447="+$("[name=id584]").val();
					}else {
						settext+="&id584="+$("[name=id584]").val()+"&id447=off";
					}
				}else{
					settext+="&"+sendname+"="+$.trim($("[name="+sendname+"]").val());
				}
			}
	});
		settext=settext.replace(/\#/g,"%23");
		
		$.ajax({
		type:"POST",url:'xml',data:'method = '+modules["batch"]+settext+"&tmp = "+Math.random(),dataType:"xml",error:function (xml) {
			$(xml).find('Error').each(function () {
				var errortext = $(this).attr('msg');
				//show_message("err",errortext);
				alert(errortext);
			});
		},success:function (xml) {
			$(xml).find('rsp').each(function () {
				var stat = $(this).attr('stat');
				if(stat == "ok") {
					//show_message("success",msg.patchSuccess);
					alert(msg.patchSuccess);
				}else if(stat == "restart"||stat == "reboot") {
					//show_message("success",msg.patchReboot);
					alert(msg.patchReboot);
				}else if(stat == "fail") {
					$(xml).find('Error').each(function () {
						var code = $(this).attr('code');
						if(code == 4) {
							//show_message("err",msg.cannotModify1);
							alert(msg.cannotModify1);
						}else if(code == 5) {
							gotologin();
						}else {
								var strArray = $(this).attr('msg').split(" ");
								var mid = strArray[1].substr(2);
								var strArray = $(this).attr('msg').split(" ");
								var mid = strArray[1].substr(2);
								showerror(mid);
								//show_message("err",msg.patchFail);
								alert(msg.patchFail);
						}
					});
				}
			});
		}
	});
	});